package com.example.module_main.viewmodel

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.example.lib_common.base.BaseViewModel
import com.example.module_main.model.AppUpdateModel
import com.example.module_main.repository.MainRepository
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class MainViewModel @Inject constructor(private val mainRepository: MainRepository):BaseViewModel() {
    private val appUpdateLiveData by lazy {
        MutableLiveData<AppUpdateModel>()
    }
    val _appUpdateLiveData : LiveData<AppUpdateModel> = appUpdateLiveData
    /**
     * 版本更新
     */
    fun checkUpDate() {
        execute(
            action = mainRepository.checkUpDate(),
            onFinish = {
                appUpdateLiveData.value = it.data
            }
        )
    }
}